package cn.duxiaod.demo.guava;

import com.google.common.util.concurrent.RateLimiter;

/**
 * Guava  RateLimiter
 */
public class RateLimiterTest {
    public static void main(String[] args) {
        RateLimiter rateLimiter = RateLimiter.create(5);
        for (int i = 0; i < 5; i++) {
            //acquire方法传入的是需要的令牌个数，当令牌不足时会进行等待，该方法返回的是等待的时间
            System.out.println(rateLimiter.acquire(1));
        }
    }
}
